package com.qingke.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Arrays;



public class JdbcBatch extends JdbcConntest {

	public static void main(String[] args) {
		
		Connection conn=getConnection();
		PreparedStatement ps=null;
		conn=getConnection();
		try {
			ps=conn.prepareStatement("insert into qingke.player(name,username,password) values(?,?,?)");
			for(int i=1;i<=20;i++){
				ps.setString(1, "Qingke"+i);
				ps.setString(2, "qingke"+i);
				ps.setString(3, "123");
				
				ps.addBatch();
			}
			int[] results = ps.executeBatch();
			System.out.println("results = "+Arrays.toString(results));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
